<template>
  <div id="app">
    <h1 align="center">投诉事务列表</h1><br>
    <el-table
      :data="tableData"
      style="width: 80%"
      align="right"
      max-height="900">
      <el-table-column
        prop="id"
        label="id"
        width="100"
        align="center">
      </el-table-column>
<!--      <el-table-column-->
<!--        prop="type_id"-->
<!--        label="类别"-->
<!--        width="100"-->
<!--      align="center">-->
<!--      </el-table-column>-->
      <el-table-column
        prop="task_id"
        label="任务id"
        width="100"
        align="center">
      </el-table-column>
      <el-table-column
        prop="lanucher"
        label="投诉者"
        width="280"
        align="center">
      </el-table-column>
      <el-table-column
        prop="undertaker"
        label="被投诉者"
        width="280"
        align="center">
      </el-table-column>
      <el-table-column
        prop="content"
        label="投诉内容"
        width="400"
        align="center">
      </el-table-column>
      <el-table-column
        label="操作"
        min-width="120"
        align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="Lock(scope.row.id, scope.row.undertaker)">封禁</el-button>
          <el-button type="primary" size="mini" @click="Ignore(scope.row.id)">忽略</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from 'axios'
// import router from '../../router'

export default {
  name: 'Complaints',
  data () {
    return {
      tableData: []
    }
  },
  methods: {
    Lock (id, undertaker) {
      axios.post(`admin/lock`, {
        id: id,
        email: undertaker
      }).then(res => {
        if (res.data.status === 100) {
          alert('处理成功')
        } else {
          alert('处理失败')
        }
      }).catch(err => {
        alert(err)
      })
    },
    Ignore (id) {
      axios.post(`admin/ignore`, {
        id: id
      }).then(res => {
        if (res.data.status === 100) {
          alert('处理成功')
        } else {
          alert('处理失败')
        }
      }).catch(err => {
        alert(err)
      })
    },
    getObj: function () {
      axios.get(`admin/getAffair`, {
        params: {
          type_id: '0'
        }
      }
      ).then(res => {
        if (res.data.status === 100) {
          this.tableData = res.data.data
          for (var i = 0; i < res.data.data.length; i++) {
            res.data.data[i].type_id = '投诉'
          }
        } else {
          alert('获取失败')
        }
      }).catch(err => {
        alert(err)
      })
    }
  },
  created () {
    this.getObj()
  }
}
</script>

<style scoped>

</style>
